//
//  TestPresentDiss.m
//  ProjectDemo
//
//  Created by IOS3 on 2018/12/14.
//  Copyright © 2018 IOS3. All rights reserved.
//

#import "TestPresentDiss.h"
#import "AppDelegate.h"

@implementation TestPresentDiss

+ (void)dismissAll {
    AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
    UIViewController *vc = app.window.rootViewController;
    
    UIViewController *presentedController = vc.presentedViewController;
    
    NSLog(@"==== %@", NSStringFromClass(vc.presentingViewController.class));
    NSLog(@"==== %@", NSStringFromClass(vc.presentationController.class));
    
    NSMutableArray *marr = [NSMutableArray array];
    
    while (presentedController) {
        NSLog(@"%@", NSStringFromClass(presentedController.class));
//        [presentedController dismissViewControllerAnimated:YES completion:nil];
        [marr addObject:presentedController];
        presentedController = presentedController.presentedViewController;
    }
    for (NSInteger i = marr.count - 1; i >= 0; i--) {
        UIViewController *vc = (UIViewController *)marr[i];
        [vc dismissViewControllerAnimated:NO completion:nil];
    }
}

@end
